/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is Canadian Weather.
 *
 * The Initial Developer of the Original Code is
 *   George Bradt.
 *
 * Portions created by the Initial Developer are Copyright (C) 2011
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   George Bradt.
 *
 * Credits:
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

var CanWeatherOptions = {
    // Alberta, British Columbia, Manitoba, New Brunswick,
    // Newfoundland and Labrador, Northwest Territories, Nova Scotia,
    // Nunavut, Ontario, Prince Edward Island, Quebec, Saskatchewan, Yukon.
    sites: [["Airdrie|0768", "Athabasca|0001", "Banff|0404", "Barrhead|0413",
             "Beaverlodge|0092", "Bow Island|0382", "Bow Valley (Provincial Park)|0379",
             "Breton|0277", "Brooks|0093", "Calgary (Olympic Park)|0126", "Calgary|0047",
             "Camrose|0311", "Canmore|0403", "Cardston|0159", "Claresholm|0120",
             "Cochrane|0493", "Cold Lake|0619", "Coronation|0111", "Crowsnest|0310",
             "Drayton Valley|0468", "Drumheller|0129", "Edmonton (Intl Aprt)|0510",
             "Edmonton|0045", "Edson|0518", "Elk Island (National Park)|0156",
             "Esther|0176", "Fort Chipewyan|0636", "Fort McMurray|0595", "Garden Creek|0167",
             "Grande Cache|0781", "Grande Prairie|0661", "Hendrickson Creek|0279",
             "High Level|0621", "High River|0383", "Highvale|0066", "Hinton|0217",
             "Jasper|0218", "Kananaskis (Nakiska Ridgetop)|0263", "Lac La Biche|0229",
             "Lacombe|0297", "Lethbridge|0652", "Lloydminster|0590", "Medicine Hat|0745",
             "Mildred Lake|0523", "Milk River|0313", "Nordegg|0448", "Okotoks|0767",
             "Onefour|0272", "Peace River|0625", "Pincher Creek|0824", "Rainbow Lake|0643",
             "Red Deer|0645", "Red Earth Creek|0299", "Rocky Mountain House|0306",
             "Slave Lake|0794", "Stavely|0384", "Stettler|0829", "Stony Plain|0453",
             "Strathmore|0068", "Suffield|0683", "Sundre|0083", "Taber|0359", "Three Hills|0179",
             "Vauxhall|0358", "Vegreville|0356", "Wainwright|0833", "Waterton Park|0170",
             "Westlock|0427", "Wetaskiwin|0312", "Whitecourt|0477", "Willow Creek (Provincial Park)|0119"],
            
            ["100 Mile House|0106", "Abbotsford|0758", "Agassiz|0399", "Atlin|0409",
             "Bella Bella|0834", "Bella Coola|0485", "Blue River|0499", "Burns Lake|0293",
             "Cache Creek|0569", "Campbell River|0488", "Cassiar|0228", "Castlegar|0497",
             "Chetwynd|0500", "Chilliwack|0398", "Clearwater|0002", "Clinton|0107",
             "Comox|0656", "Courtenay|0657", "Cranbrook|0741", "Creston|0212",
             "Cummins Lakes (Provincial Park)|0845", "Dawson Creek|0509", "Dease Lake|0227",
             "Dome Creek|0009", "Esquimalt|0286", "Estevan Point|0132", "Fort Nelson|0771",
             "Fort St. John|0746", "Gibsons|0316", "Golden|0527", "Gonzales Point|0234",
             "Good Hope Lake|0647", "Grand Forks|0004", "Gulf Islands (Southern)|0155",
             "Hope|0547", "Hope Slide|0226", "Invermere|0008", "Kamloops|0568",
             "Kelowna|0592", "Kitimat|0756", "Kootenay (National Park)|0391", "Liard River|0377",
             "Lillooet|0222", "Lytton|0242", "Mackenzie|0805", "Malahat|0224", "Masset|0007",
             "McBride|0005", "Merritt|0006", "Muncho Lake|0376", "Nakusp|0259", "Nanaimo|0496",
             "Nelson|0258", "Osoyoos|0397", "Pemberton|0173", "Penticton|0772",
             "Pitt Meadows|0247", "Port Alberni|0294", "Port Hardy|0799", "Powell River|0634",
             "Prince George|0146", "Prince Rupert|0633", "Princeton|0291", "Puntzi Mountain|0292",
             "Quesnel|0671", "Revelstoke|0679", "Rock Creek|0396", "Salmon Arm|0324",
             "Sandspit|0795", "Sechelt|0317", "Smithers|0770", "Sparwood|0175", "Squamish|0323",
             "Stewart|0828", "Summerland|0351", "Tatlayoko Lake|0465", "Terrace|0757",
             "Tetsa River (Provincial Park)|0341", "Tofino|0481", "Trail|0471", "Ucluelet|0482",
             "Valemount|0003", "Vancouver|0141", "Vanderhoof|0754", "Vernon|0216",
             "Victoria|0775", "Victoria (Hartland)|0792", "Victoria (University of)|0390",
             "Victoria Harbour|0735", "Whistler|0078", "White Rock|0373", "Williams Lake|0739",
             "Yoho (National Park)|0392"],
            
            ["Altona|0171", "Arnes|0533", "Bachelors Island|0091", "Berens River|0102",
             "Bissett|0012", "Bloodvein|0101", "Brandon|0492", "Brochet|0778", "Carberry|0401",
             "Carman|0257", "Churchill|0779", "Dauphin|0508", "Deerwood|0256", "Delta|0831",
             "Dominion City|0152", "Emerson|0153", "Fisher Branch|0339", "Flin Flon|0015",
             "Gillam|0543", "Gimli|0534", "Gods Lake|0566", "Grand Beach|0191",
             "Grand Rapids|0207", "Gretna|0172", "Hunters Point|0178", "Island Lake|0565",
             "Leaf Rapids|0776", "Little Grand Rapids|0010", "Lynn Lake|0777", "McCreary|0276",
             "Melita|0136", "Minnedosa|0490", "Morden|0444", "Morris|0150", "Norway House|0616",
             "Oak Point|0273", "Oxford House|0011", "Pilot Mound|0289", "Pinawa|0130",
             "Pine Falls|0189", "Poplar River|0378", "Portage la Prairie|0626",
             "Pukatawagan|0161", "Richer|0734", "Roblin|0380", "Shamattawa|0013",
             "Shilo|0402", "Shoal Lake|0352", "Snow Lake|0160", "Souris|0491",
             "Sprague|0337", "Steinbach|0151", "Swan River|0139", "Tadoule Lake|0417",
             "The Pas|0644", "Thompson|0695", "Turtle Mountain (Provincial Park)|0137",
             "Victoria Beach|0190", "Virden|0135", "Vita|0154", "Wasagaming|0375",
             "Whiteshell|0131", "Winkler|0445", "Winnipeg|0193", "Winnipeg (The Forks)|0472",
             "York Factory|0014"],
            
            ["Bas-Caraquet|0386", "Bathurst|0806", "Bouctouche|0033", "Campbellton|0807",
             "Charlo|0809", "Chipman|0502", "Dalhousie|0808", "Doaktown|0503",
             "Edmundston|0043", "Fredericton|0250", "Fundy (National Park)|0688",
             "Grand Falls|0201", "Grand Manan|0622", "Hopewell|0655", "Kouchibouguac|0038",
             "Miramichi|0036", "Miscou Island|0243", "Moncton|0654",
             "Mount Carleton (Provincial Park)|0198", "Oromocto|0521", "Point Escuminac|0037",
             "Point Lepreau|0285", "Quispamsis|0685", "Richibucto|0034", "Rogersville|0035",
             "Sackville|0449", "Saint Andrews|0331", "Saint John|0687", "Saint-Quentin|0199",
             "Shediac|0653", "St. Leonard|0200", "St. Stephen|0332", "Sussex|0686",
             "Tracadie-Sheila|0385", "Woodstock|0522"],
            
            ["Argentia|0082", "Badger|0116", "Bay Roberts|0018", "Bonavista|0041",
             "Buchans|0117", "Burgeo|0032", "Campbellton|0668", "Cape Race|0298",
             "Cartwright|0100", "Channel - Port aux Basques|0400", "Churchill Falls|0832",
             "Clarenville|0466", "Corner Brook|0221", "Daniel's Harbour|0115",
             "Deer Lake|0507", "Englee|0112", "Gander|0667", "Grand Bank|0475",
             "Grand Falls/Windsor|0118", "Gros Morne|0457", "Happy Valley-Goose Bay|0780",
             "Hopedale|0181", "La Scie|0079", "Labrador City|0737", "Lewisporte|0669",
             "Makkovik|0526", "Marble Mountain|0220", "Mary's Harbour|0594", "Marystown|0474",
             "Musgrave Harbour|0016", "Nain|0162", "New-Wes-Valley|0017", "Port au Choix|0114",
             "Rocky Harbour|0456", "St Alban's|0019", "St. Anthony|0128", "St. John's|0280",
             "St. Lawrence|0039", "Stephenville|0567", "Terra Nova (National Park)|0467",
             "Twillingate|0122", "Wabush Lake|0736", "Winterland|0473", "Wreckhouse|0042"],
            
            ["Aklavik|0570", "Colville Lake|0164", "Deline|0423", "Detah|0791",
             "Ekati (Lac de Gras)|0618", "Enterprise|0560", "Fort Good Hope|0818",
             "Fort Liard|0210", "Fort McPherson|0816", "Fort Providence|0188",
             "Fort Resolution|0524", "Fort Simpson|0525", "Fort Smith|0690", "Gameti|0388",
             "Hay River|0561", "Indin River|0389", "Inuvik|0519", "Lutselke|0443",
             "Nahanni Butte|0476", "Norman Wells|0720", "Paulatuk|0759", "Sachs Harbour|0338",
             "Trout Lake|0340", "Tuktoyaktuk|0830", "Tulita|0817", "Ulukhaktok|0432",
             "Wekweeti|0442", "Whati|0249", "Wrigley|0740", "Yellowknife|0366"],
            
            ["Amherst|0450", "Annapolis Royal|0802", "Antigonish|0462", "Baccaro Point|0110",
             "Baddeck|0265", "Beaver Island|0096", "Bridgetown|0804", "Bridgewater|0441",
             "Brier Island|0365", "Cape George|0463", "Caribou|0090", "Chéticamp|0420",
             "Digby|0364", "Economy|0814", "Fourchu Head|0020", "Grand Étang|0405",
             "Greenwood|0803", "Guysborough|0464", "Halifax|0318", "Halifax (Shearwater)|0084",
             "Hart Island|0308", "Ingonish|0433", "Kejimkujik (National Park)|0223",
             "Kentville|0439", "Liverpool|0371", "Lunenburg|0440", "Malay Falls|0447",
             "New Glasgow|0089", "North East Margaree|0264", "North Mountain (Cape Breton)|0021",
             "Parrsboro|0040", "Port Hawkesbury|0460", "Sheet Harbour|0446", "Shelburne|0109",
             "St. Peter's|0307", "Sydney|0670", "Tatamagouche|0812", "Tracadie|0461",
             "Truro|0813", "Western Head|0370", "Windsor|0438", "Yarmouth|0649"],
            
            ["Alert|0821", "Arctic Bay|0412", "Arviat|0511", "Baker Lake|0487",
             "Cambridge Bay|0495", "Cape Dorset|0694", "Chesterfield|0501", "Clyde River|0504",
             "Coral Harbour|0798", "Ennadai|0206", "Eureka|0140", "Gjoa Haven|0820",
             "Grise Fiord|0177", "Hall Beach|0714", "Igloolik|0540", "Iqaluit|0394",
             "Kimmirut|0587", "Kugaaruk|0065", "Kugluktuk|0498", "Nanisivik|0693",
             "Pangnirtung|0750", "Pond Inlet|0564", "Qikiqtarjuaq|0716", "Rankin Inlet|0678",
             "Repulse Bay|0713", "Resolute|0672", "Sanikiluaq|0689", "Taloyoak|0774",
             "Whale Cove|0749"],
            
            ["Alexandria|0070", "Algonquin Park (Brent)|0073",
             "Algonquin Park (Lake of Two Rivers)|0074", "Alliston|0489", "Apsley|0304",
             "Armstrong|0520", "Atikokan|0103", "Attawapiskat|0024", "Bancroft|0301",
             "Barrie|0415", "Barry's Bay|0302", "Belleville|0703", "Big Trout Lake|0697",
             "Blind River|0513", "Bracebridge|0641", "Brampton|0658", "Brantford|0550",
             "Brockville|0168", "Burk's Falls|0637", "Burlington|0368", "Caledon|0787",
             "Cambridge|0572", "Chapleau|0588", "Chatham-Kent|0454", "Cobourg|0251",
             "Cochrane|0706", "Collingwood|0108", "Cornwall|0071", "Deep River|0732",
             "Dorion|0660", "Dryden|0546", "Dunchurch|0452", "Dundalk|0237", "Ear Falls|0428",
             "Earlton|0752", "Elliot Lake|0512", "Fort Albany|0597", "Fort Erie|0282",
             "Fort Frances|0104", "Fort Severn|0517", "Gananoque|0169", "Goderich|0165",
             "Gogama|0025", "Gore Bay|0790", "Gravenhurst|0638", "Greater Napanee|0528",
             "Greenstone (Beardmore)|0418", "Greenstone (Geraldton)|0538",
             "Greenstone (Nakina)|0539", "Guelph|0571", "Gull Bay|0395", "Haldimand County|0548",
             "Haliburton|0303", "Halton Hills|0789", "Hamilton|0549", "Hawkesbury|0069",
             "Hearst|0266", "Hornepayne|0267", "Huntsville|0640", "Ignace|0819",
             "Kakabeka Falls|0659", "Kaladar|0305", "Kapuskasing|0782",
             "Kawartha Lakes (Fenelon Falls)|0632", "Kawartha Lakes (Lindsay)|0631",
             "Kemptville|0436", "Kenora|0651", "Killarney|0088", "Kincardine|0166",
             "Kingston|0531", "Kirkland Lake|0437", "Kitchener-Waterloo|0573",
             "Lake Superior (Provincial Park)|0763", "Lambton Shores|0744",
             "Lansdowne House|0233", "Leamington|0431", "Lincoln|0470", "London|0326",
             "Marathon|0022", "Markham|0585", "Midland|0281", "Mine Centre|0105",
             "Mississauga|0786", "Montreal River Harbour|0762", "Moosonee|0596",
             "Morrisburg|0072", "Mount Forest|0240", "Muskoka|0642", "New Tecumseth|0429",
             "Newmarket|0582", "Niagara Falls|0692", "Nipigon|0419", "Norfolk|0426",
             "North Bay|0765", "North Perth|0238", "Oakville|0367", "Ogoki|0231",
             "Orangeville|0815", "Orillia|0414", "Oshawa|0707", "Ottawa (Kanata - Orléans)|0430",
             "Ottawa (Richmond - Metcalfe)|0623", "Owen Sound|0728", "Oxtongue Lake|0075",
             "Parry Sound|0451", "Peawanuck|0374", "Pembroke|0730", "Petawawa|0729",
             "Peterborough|0629", "Pickering|0710", "Pickle Lake|0628", "Pikangikum|0677",
             "Port Carling|0639", "Port Colborne|0283", "Port Elgin|0725", "Port Perry|0630",
             "Prince Edward (Picton)|0702", "Quinte West|0704", "Red Lake|0676", "Renfrew|0731",
             "Richmond Hill|0773", "Rodney|0455", "Rondeau (Provincial Park)|0080",
             "Sachigo Lake|0696", "Sandy Lake|0826", "Sarnia|0796", "Saugeen Shores|0726",
             "Sault Ste. Marie|0479", "Savant Lake|0747", "Sharbot Lake|0435", "Shelburne|0239",
             "Simcoe|0424", "Sioux Lookout|0748", "Sioux Narrows|0650", "Smiths Falls|0434",
             "South Bruce Peninsula|0727", "St. Catharines|0691", "St. Thomas|0329",
             "Stirling|0700", "Stratford|0325", "Strathroy|0328", "Sudbury (Greater)|0843",
             "Sydenham|0529", "Temiskaming Shores|0753", "Terrace Bay|0023", "Thunder Bay|0411",
             "Tillsonburg|0425", "Timmins|0705", "Tobermory|0422", "Toronto|0458",
             "Toronto Island|0785", "Trenton|0701", "Upsala|0127", "Vaughan|0584",
             "Vineland|0469", "Walkerton|0236", "Wawa|0761", "Webequie|0232", "Welland|0076",
             "West Nipissing|0766", "Westport|0530", "Whitby|0708", "White River|0764",
             "Wiarton|0724", "Winchester|0077", "Windsor|0646", "Wingham|0235",
             "Woodstock|0327", "Wunnummin Lake|0698"],
            
            ["Charlottetown|0583", "East Point|0138", "Maple Plains|0026", "North Cape|0252",
             "St. Peters Bay|0827", "Summerside|0562"],
            
            ["Akulivik|0578", "Alma|0197", "Amos|0718", "Amqui|0406", "Asbestos|0682",
             "Aupaluk|0586", "Bagotville|0486", "Baie-Comeau|0483", "Baie-James|0580",
             "Baie-Saint-Paul|0342", "Beauceville|0185", "Beauharnois|0044", "Bécancour|0347",
             "Bernières|0205", "Berthierville|0143", "Blainville|0603", "Blanc-Sablon|0494",
             "Boisbriand|0604", "Bonaventure|0269", "Candiac|0046", "Cap Chat|0320",
             "Carignan|0553", "Carleton-sur-Mer|0811", "Chambly|0554", "Chandler|0315",
             "Charlevoix|0194", "Chelsea|0615", "Chevery|0121", "Chibougamau|0598",
             "Coaticook|0296", "Contrecoeur|0144", "Cowansville|0053", "Delson|0769",
             "Deux-Montagnes|0361", "Dolbeau-Mistassini|0270", "Donnacona|0182",
             "Drummondville|0261", "Escoumins|0028", "Farnham|0063", "Fermont|0738",
             "Forestville|0484", "Forillon|0536", "Forillon (National Park)|0537",
             "Gaspé|0535", "Gaspésie (Parc national)|0321", "Gatineau|0611",
             "Gouin (Réservoir)|0288", "Granby|0052", "Grande-Vallée|0319", "Havre St-Pierre|0541",
             "Huntingdon|0099", "Îles-de-la-Madeleine|0174", "Inukjuak|0627", "Ivujivik|0563",
             "Joliette|0721", "Kamouraska|0335", "Kangiqsualujjuaq|0591", "Kangiqsujuaq|0574",
             "Kangirsuk|0480", "Kuujjuaq|0719", "Kuujjuarapik|0542", "L'Assomption|0142",
             "L'Islet|0336", "La Grande Rivière|0532", "La Grande-Quatre|0478", "La Malbaie|0333",
             "La Prairie|0048", "La Sarre|0354", "La Tuque|0124",
             "La Vérendrye (Réserve faunique)|0245", "Lac Raglan|0575", "Lac Saint-Jean|0674",
             "Lac-Mégantic|0186", "Lachute|0602", "Lanaudière|0459",
             "Laurentides (Réserve faunique)|0284", "Laval|0712", "Le Gardeur|0149",
             "Lévis|0416", "Longueuil|0551", "Lorraine|0605", "Louiseville|0348",
             "Magog|0345", "Manicouagan|0123", "Maniwaki|0244", "Marieville|0060",
             "Mascouche|0145", "Matagami|0617", "Matane|0784", "Matapedia|0407", "Mauricie|0125",
             "Mingan|0094", "Mirabel|0600", "Mont Saint-Hilaire|0555", "Mont-Joli|0783",
             "Mont-Laurier|0246", "Mont-Tremblant|0213", "Montmagny|0334", "Montréal|0635",
             "Murdochville|0027", "Natashquan|0610", "New Carlisle|0268", "Nicolet|0260",
             "Otterburn Park|0556", "Papineau|0612", "Parent|0287", "Percé|0314", "Pincourt|0363",
             "Pointe-à-la-Croix|0810", "Pontiac|0613", "Port-Cartier|0801", "Port-Menier|0097",
             "Prévost|0055", "Puvirnituq|0711", "Quaqtaq|0544", "Québec|0620", "Repentigny|0755",
             "Richelieu|0552", "Rigaud|0061", "Rimouski|0393", "Rivière-du-Loup|0253",
             "Roberval|0673", "Rosemère|0606", "Rouyn-Noranda|0353", "Saguenay|0211",
             "Saint-Amable|0557", "Saint-Basile Le Grand|0558", "Saint-Constant|0049",
             "Saint-Eustache|0609", "Saint-Félicien|0675", "Saint-Georges|0187",
             "Saint-Hyacinthe|0059", "Saint-Jean-sur-Richelieu|0202", "Saint-Jérôme|0601",
             "Saint-Lazare|0062", "Saint-Lin-Laurentides|0057", "Saint-Luc|0203",
             "Saint-Michel-des-Saints|0029", "Saint-Nicéphore|0262", "Saint-Rémi|0051",
             "Saint-Sauveur|0058", "Saint-Timothée|0742", "Sainte-Agathe|0214",
             "Sainte-Anne-Des-Monts|0322", "Sainte-Anne-Des-Plaines|0607", "Sainte-Catherine|0050",
             "Sainte-Julie|0559", "Sainte-Sophie|0056", "Sainte-Thérèse|0608",
             "Salaberry-de-Valleyfield|0098", "Salluit|0793", "Schefferville|0577",
             "Sept-Îles|0800", "Shawinigan|0709", "Sherbrooke|0681", "Sorel-Tracy|0147",
             "Sutton|0163", "Tadoussac|0295", "Tasiujaq|0699", "Témiscamingue|0085",
             "Temiscouata|0255", "Terrebonne|0290", "Thetford Mines|0064", "Tracy|0148",
             "Trois-Pistoles|0254", "Trois-Rivières|0346", "Umiujaq|0599", "Val-d'Or|0717",
             "Val-des-Monts|0614", "Vallée de la Matapédia|0408", "Vanier|0204", "Varennes|0180",
             "Vaudreuil-Dorion|0362", "Victoriaville|0054", "Waskaganish|0579"],
            
            ["Assiniboia|0209", "Biggar|0343", "Broadview|0192", "Buffalo Narrows|0723",
             "Canora|0662", "Carlyle|0515", "Collins Bay|0369", "Coronach|0081",
             "Cypress Hills (Provincial Park)|0360", "Eastend|0134", "Elbow|0274",
             "Estevan|0516", "Fort Qu'Appelle|0087", "Hudson Bay|0545", "Humboldt|0196",
             "Indian Head|0086", "Kamsack|0664", "Key Lake|0576", "Kindersley|0581",
             "La Loche|0722", "La Ronge|0715", "Last Mountain Lake (Sanctuary)|0381",
             "Leader|0219", "Lloydminster|0835", "Lucky Lake|0230", "Maple Creek|0248",
             "Meadow Lake|0589", "Melfort|0158", "Melville|0665", "Moose Jaw|0822",
             "Moosomin|0733", "Nipawin|0095", "North Battleford|0666", "Outlook|0387",
             "Oxbow|0514", "Pelican Narrows|0067", "Prince Albert|0624", "Regina|0788",
             "Rockglen|0225", "Rosetown|0300", "Rosthern|0743", "Saskatoon|0797",
             "Scott|0344", "Shaunavon|0133", "Southend Reindeer|0208", "Spiritwood|0330",
             "Stony Rapids|0684", "Swift Current|0355", "Tisdale|0157", "Uranium City|0113",
             "Val Marie|0357", "Waskesiu Lake|0241", "Watrous|0195", "Weyburn|0372",
             "Wynyard|0278", "Yorkton|0663"],
            
            ["Beaver Creek|0751", "Burwash Landing|0506", "Carcross|0760", "Carmacks|0421",
             "Dawson|0275", "Dempster (Highway)|0031", "Faro|0349", "Haines Junction|0183",
             "Kluane Lake|0505", "Mayo|0593", "Old Crow|0823", "Rancheria|0030",
             "Rock River|0309", "Ross River|0350", "Teslin|0410", "Watson Lake|0648",
             "Whitehorse|0825"]],
    
    // Alberta, British Columbia, Manitoba, New Brunswick, Newfoundland and Labrador, Nova Scotia,
    // Ontario, Quebec, Saskatchewan.
    radarStations: [["Calgary|XSM", "Cold Lake|WHN", "Edmonton|WHK", "Grande Prairie|WWW",
                     "Medicine Hat|XBU"],
                    
                    ["Prince George|XPG", "Vancouver|WUJ", "Vernon|XSS", "Victoria|XSI"],
                    
                    ["Brandon|XFW", "Winnipeg|XWL"],
                    
                    ["Fredericton|XNC"],
                    
                    ["Corner Brook|XME", "St. John's|WTP"],
                    
                    ["Halifax|XGO", "Sydney|XMB"],
                    
                    ["Dryden|XDR", "London|WSO", "Ottawa|XFT", "Sault Ste. Marie|WGJ",
                     "Sudbury|WBI", "Thunder Bay|XNI", "Timmins|XTI", "Toronto|WKR"],
                    
                    ["Mont-Joli|XAM", "Montréal|WMN", "Rouyn-Noranda|XLA",
                     "Saguenay|WMB", "Trois-Rivières|WVY"],
                    
                    ["Regina|XBE", "Saskatoon|XRA"]],
    
    initPicker: function (aElement, aBackgroundColor, aTextColor) {
        aElement.disabled = false;
        aElement.value = aBackgroundColor;
        aElement.style.setProperty('background-color', aBackgroundColor, '');

        if ( typeof(aTextColor) != "undefined" && aTextColor != '' ) {
            // Set text color for background pickers.
            aElement.style.setProperty('color', aTextColor, '');
        }
    },
    
    // Returns the value for the checked radio button.
    getRadioGroupValue: function (aGroupName) {
        var radios = document.getElementsByName(aGroupName);
        var returnValue = '';
    
        for ( let i = 0; i < radios.length; i++ ) {
            if ( radios[i].checked ) {
                returnValue = radios[i].value;
                break;
            }
        }
        
        return returnValue;
    },
    
    // Checks the appropriate radio button based on a pref or stored value.
    setRadioGroup: function (aGroupName, aValue) {
        var radios = document.getElementsByName(aGroupName);
    
        for ( let i = 0; i < radios.length; i++ ) {
            if ( radios[i].value === aValue ) {
                radios[i].checked = true;
                break;
            }
        }
    }
};

// Handle user-defined event emitted from add-on code when the options panel is shown.
// Initialize panel elements.
self.port.on('show', function(aOptions) {
    // Location tab.
    var provincesSelect = document.getElementById('canw-provinces');
    provincesSelect.selectedIndex = aOptions.location.provinceIndex;

    var sitesSelect = document.getElementById('canw-sites');

    // Remove option elements from sites select.
    while ( sitesSelect.hasChildNodes() ) {
        sitesSelect.removeChild(sitesSelect.lastChild);
    }

    var optionElement, site;

    for ( let i = 0; i < CanWeatherOptions.sites[aOptions.location.provinceIndex].length; i++ ) {
        site = CanWeatherOptions.sites[aOptions.location.provinceIndex][i].split('|');
        optionElement = document.createElement('option');
        optionElement.text = site[0];
        optionElement.value = 's000' + site[1];
        sitesSelect.appendChild(optionElement);
    }

    sitesSelect.selectedIndex = aOptions.location.siteIndex;

    // Radar tab.
    var radarProvincesSelect = document.getElementById('canw-radarProvinces');
    radarProvincesSelect.selectedIndex = aOptions.radar.provinceIndex;

    var radarStationsSelect = document.getElementById('canw-radarStations');

    // Remove option elements from radarStations select.
    while ( radarStationsSelect.hasChildNodes() ) {
        radarStationsSelect.removeChild(radarStationsSelect.lastChild);
    }

    for ( let i = 0; i < CanWeatherOptions.radarStations[aOptions.radar.provinceIndex].length; i++ ) {
        optionElement = document.createElement('option');
        optionElement.text =
                CanWeatherOptions.radarStations[aOptions.radar.provinceIndex][i].split('|')[0];
        optionElement.value = CanWeatherOptions.radarStations[aOptions.radar.provinceIndex][i];
        radarStationsSelect.appendChild(optionElement);
    }

    radarStationsSelect.selectedIndex = aOptions.radar.stationIndex;
    radarProvincesSelect.disabled = !aOptions.radarEnabled;
    radarStationsSelect.disabled = !aOptions.radarEnabled;
    
    document.getElementById('canw-radarEnable').checked = aOptions.radarEnabled;

    // Display tab.
    document.getElementById('canw-temperature').checked =
            aOptions.toolbarDisplay.showTemperature;
    document.getElementById('canw-wind').checked =
            aOptions.toolbarDisplay.showWind;
    document.getElementById('canw-windChill').checked =
            aOptions.toolbarDisplay.showWindChill;
    document.getElementById('canw-humidity').checked =
            aOptions.toolbarDisplay.showHumidity;
    document.getElementById('canw-humidex').checked =
            aOptions.toolbarDisplay.showHumidex;
    document.getElementById('canw-condition').checked =
            aOptions.toolbarDisplay.showCondition;
    document.getElementById('canw-conditionIcon').checked =
            aOptions.toolbarDisplay.showConditionIcon;
    document.getElementById('canw-showAllInPanel').checked =
            aOptions.conditionsPanelEnabled;
    document.getElementById('canw-warnings').checked =
            aOptions.warningPanelEnabled;
    document.getElementById('canw-warningsOnce').checked =
            aOptions.showWarningOnlyOnce;
    document.getElementById('canw-warningsOnce').disabled =
            !aOptions.warningPanelEnabled;
    
    document.getElementById('canw-today').checked =
            aOptions.forecastInToolbar.showToday;
    document.getElementById('canw-tonight').checked =
            aOptions.forecastInToolbar.showTonight;
    document.getElementById('canw-todayplus1').checked =
            aOptions.forecastInToolbar.showTodayPlus1;
    document.getElementById('canw-todayplus2').checked =
            aOptions.forecastInToolbar.showTodayPlus2;
    document.getElementById('canw-dayLabel').checked =
            aOptions.forecastInToolbar.showDayLabel;
    document.getElementById('canw-forecastTemp').checked =
            aOptions.forecastInToolbar.showForecastTemperature;
    document.getElementById('canw-pop').checked =
            aOptions.forecastInToolbar.showPop;
    document.getElementById('canw-forecastIcon').checked =
            aOptions.forecastInToolbar.showForecastIcon;
    
    // Style tab.
    document.getElementById('canw-bold').checked = aOptions.toolbarStyle.bold;
    document.getElementById('canw-italic').checked = aOptions.toolbarStyle.italic;
    
    var fontsizeSelect = document.getElementById('canw-sizes');
    fontsizeSelect.selectedIndex = aOptions.toolbarStyle.fontsizeIndex;

    if ( aOptions.toolbarColorEnabled ) {
        var normalCheckbox = document.getElementById('canw-normal');
        var priorityLowCheckbox = document.getElementById('canw-priorityLow');
        var priorityMediumCheckbox = document.getElementById('canw-priorityMedium');
        var priorityHighCheckbox = document.getElementById('canw-priorityHigh');
        var priorityUrgentCheckbox = document.getElementById('canw-priorityUrgent');

        normalCheckbox.checked = aOptions.toolbarStyle.color.normal[0] ||
                                 aOptions.toolbarStyle.color.normal[1];
        priorityLowCheckbox.checked = aOptions.toolbarStyle.color.priorityLow[0] ||
                                      aOptions.toolbarStyle.color.priorityLow[1];
        priorityMediumCheckbox.checked = aOptions.toolbarStyle.color.priorityMedium[0] ||
                                         aOptions.toolbarStyle.color.priorityMedium[1];
        priorityHighCheckbox.checked = aOptions.toolbarStyle.color.priorityHigh[0] ||
                                       aOptions.toolbarStyle.color.priorityHigh[1];
        priorityUrgentCheckbox.checked = aOptions.toolbarStyle.color.priorityUrgent[0] ||
                                         aOptions.toolbarStyle.color.priorityUrgent[1];

        if ( normalCheckbox.checked ) {
            CanWeatherOptions.initPicker(document.getElementById('canw-textColorNormal'),
                                         aOptions.toolbarStyle.color.normal[0]);
            CanWeatherOptions.initPicker(document.getElementById('canw-backgroundColorNormal'),
                                         aOptions.toolbarStyle.color.normal[1],
                                         aOptions.toolbarStyle.color.normal[0]);
        }

        if ( priorityLowCheckbox.checked ) {
            CanWeatherOptions.initPicker(document.getElementById('canw-textColorLow'),
                                         aOptions.toolbarStyle.color.priorityLow[0]);
            CanWeatherOptions.initPicker(document.getElementById('canw-backgroundColorLow'),
                                         aOptions.toolbarStyle.color.priorityLow[1],
                                         aOptions.toolbarStyle.color.priorityLow[0]);
        }

        if ( priorityMediumCheckbox.checked ) {
            CanWeatherOptions.initPicker(document.getElementById('canw-textColorMedium'),
                                         aOptions.toolbarStyle.color.priorityMedium[0]);
            CanWeatherOptions.initPicker(document.getElementById('canw-backgroundColorMedium'),
                                         aOptions.toolbarStyle.color.priorityMedium[1],
                                         aOptions.toolbarStyle.color.priorityMedium[0]);
        }

        if ( priorityHighCheckbox.checked ) {
            CanWeatherOptions.initPicker(document.getElementById('canw-textColorHigh'),
                                         aOptions.toolbarStyle.color.priorityHigh[0]);
            CanWeatherOptions.initPicker(document.getElementById('canw-backgroundColorHigh'),
                                         aOptions.toolbarStyle.color.priorityHigh[1],
                                         aOptions.toolbarStyle.color.priorityHigh[0]);
        }

        if ( priorityUrgentCheckbox.checked ) {
            CanWeatherOptions.initPicker(document.getElementById('canw-textColorUrgent'),
                                         aOptions.toolbarStyle.color.priorityUrgent[0]);
            CanWeatherOptions.initPicker(document.getElementById('canw-backgroundColorUrgent'),
                                         aOptions.toolbarStyle.color.priorityUrgent[1],
                                         aOptions.toolbarStyle.color.priorityUrgent[0]);
        }
    }

    // Other tab.
    document.getElementById('canw-english').checked =
            ( aOptions.language == 'e' ) ? true : false;
    document.getElementById('canw-minutes').value = aOptions.frequencyMilli / 60000;
    document.getElementById('canw-buttonRebuildToolbar').disabled = !aOptions.location.siteCode;
});

// Add event listeners to our tabs.
document.getElementById('canw-tab1').addEventListener('click', function(aEvent) {
    document.getElementById('canw-tab1').style.backgroundColor = "lightgrey";
    document.getElementById('canw-tab2').style.backgroundColor = "white";
    document.getElementById('canw-tab3').style.backgroundColor = "white";
    document.getElementById('canw-tab4').style.backgroundColor = "white";
    document.getElementById('canw-tab5').style.backgroundColor = "white";
    document.getElementById('canw-tab6').style.backgroundColor = "white";

    document.getElementById('canw-content1').style.zIndex = 6;
    document.getElementById('canw-content2').style.zIndex = 5;
    document.getElementById('canw-content3').style.zIndex = 4;
    document.getElementById('canw-content4').style.zIndex = 3;
    document.getElementById('canw-content5').style.zIndex = 2;
    document.getElementById('canw-content6').style.zIndex = 1;
}, true);

document.getElementById('canw-tab2').addEventListener('click', function(aEvent) {
    document.getElementById('canw-tab1').style.backgroundColor = "white";
    document.getElementById('canw-tab2').style.backgroundColor = "lightgrey";
    document.getElementById('canw-tab3').style.backgroundColor = "white";
    document.getElementById('canw-tab4').style.backgroundColor = "white";
    document.getElementById('canw-tab5').style.backgroundColor = "white";
    document.getElementById('canw-tab6').style.backgroundColor = "white";

    document.getElementById('canw-content1').style.zIndex = 1;
    document.getElementById('canw-content2').style.zIndex = 6;
    document.getElementById('canw-content3').style.zIndex = 2;
    document.getElementById('canw-content4').style.zIndex = 3;
    document.getElementById('canw-content5').style.zIndex = 4;
    document.getElementById('canw-content6').style.zIndex = 5;
}, true);

document.getElementById('canw-tab3').addEventListener('click', function(aEvent) {
    document.getElementById('canw-tab1').style.backgroundColor = "white";
    document.getElementById('canw-tab2').style.backgroundColor = "white";
    document.getElementById('canw-tab3').style.backgroundColor = "lightgrey";
    document.getElementById('canw-tab4').style.backgroundColor = "white";
    document.getElementById('canw-tab5').style.backgroundColor = "white";
    document.getElementById('canw-tab6').style.backgroundColor = "white";

    document.getElementById('canw-content1').style.zIndex = 1;
    document.getElementById('canw-content2').style.zIndex = 2;
    document.getElementById('canw-content3').style.zIndex = 6;
    document.getElementById('canw-content4').style.zIndex = 3;
    document.getElementById('canw-content5').style.zIndex = 4;
    document.getElementById('canw-content6').style.zIndex = 5;
}, true);

document.getElementById('canw-tab4').addEventListener('click', function(aEvent) {
    document.getElementById('canw-tab1').style.backgroundColor = "white";
    document.getElementById('canw-tab2').style.backgroundColor = "white";
    document.getElementById('canw-tab3').style.backgroundColor = "white";
    document.getElementById('canw-tab4').style.backgroundColor = "lightgrey";
    document.getElementById('canw-tab5').style.backgroundColor = "white";
    document.getElementById('canw-tab6').style.backgroundColor = "white";

    document.getElementById('canw-content1').style.zIndex = 1;
    document.getElementById('canw-content2').style.zIndex = 2;
    document.getElementById('canw-content3').style.zIndex = 3;
    document.getElementById('canw-content4').style.zIndex = 6;
    document.getElementById('canw-content5').style.zIndex = 4;
    document.getElementById('canw-content6').style.zIndex = 5;
}, true);

document.getElementById('canw-tab5').addEventListener('click', function(aEvent) {
    document.getElementById('canw-tab1').style.backgroundColor = "white";
    document.getElementById('canw-tab2').style.backgroundColor = "white";
    document.getElementById('canw-tab3').style.backgroundColor = "white";
    document.getElementById('canw-tab4').style.backgroundColor = "white";
    document.getElementById('canw-tab5').style.backgroundColor = "lightgrey";
    document.getElementById('canw-tab6').style.backgroundColor = "white";

    document.getElementById('canw-content1').style.zIndex = 1;
    document.getElementById('canw-content2').style.zIndex = 2;
    document.getElementById('canw-content3').style.zIndex = 3;
    document.getElementById('canw-content4').style.zIndex = 4;
    document.getElementById('canw-content5').style.zIndex = 6;
    document.getElementById('canw-content6').style.zIndex = 5;
}, true);

document.getElementById('canw-tab6').addEventListener('click', function(aEvent) {
    document.getElementById('canw-tab1').style.backgroundColor = "white";
    document.getElementById('canw-tab2').style.backgroundColor = "white";
    document.getElementById('canw-tab3').style.backgroundColor = "white";
    document.getElementById('canw-tab4').style.backgroundColor = "white";
    document.getElementById('canw-tab5').style.backgroundColor = "white";
    document.getElementById('canw-tab6').style.backgroundColor = "lightgrey";

    document.getElementById('canw-content1').style.zIndex = 1;
    document.getElementById('canw-content2').style.zIndex = 2;
    document.getElementById('canw-content3').style.zIndex = 3;
    document.getElementById('canw-content4').style.zIndex = 4;
    document.getElementById('canw-content5').style.zIndex = 5;
    document.getElementById('canw-content6').style.zIndex = 6;
}, true);

// Add event listener to the provinces select.
document.getElementById('canw-provinces').addEventListener('click', function(aEvent) {
    var provinceIndex = document.getElementById('canw-provinces').selectedIndex;
    var sitesSelect = document.getElementById('canw-sites');

    // Remove option elements from sites select.
    while ( sitesSelect.hasChildNodes() ) {
        sitesSelect.removeChild(sitesSelect.lastChild);
    }

    var optionElement, site;

    for ( let i = 0; i < CanWeatherOptions.sites[provinceIndex].length; i++ ) {
        site = CanWeatherOptions.sites[provinceIndex][i].split('|');
        optionElement = document.createElement('option');
        optionElement.text = site[0];
        optionElement.value = 's000' + site[1];
        sitesSelect.appendChild(optionElement);
    }

    sitesSelect.selectedIndex = 0;
}, true);

// Add event listener to the radar provinces select.
document.getElementById('canw-radarProvinces').addEventListener('click', function(aEvent) {
    var radarProvinceIndex = document.getElementById('canw-radarProvinces').selectedIndex;
    var radarStationsSelect = document.getElementById('canw-radarStations');

    // Remove option elements from radarStations select.
    while ( radarStationsSelect.hasChildNodes() ) {
        radarStationsSelect.removeChild(radarStationsSelect.lastChild);
    }

    var optionElement;

    for ( let i = 0; i < CanWeatherOptions.radarStations[radarProvinceIndex].length; i++ ) {
        optionElement = document.createElement('option');
        optionElement.text =
                CanWeatherOptions.radarStations[radarProvinceIndex][i].split('|')[0];
        optionElement.value = CanWeatherOptions.radarStations[radarProvinceIndex][i];
        radarStationsSelect.appendChild(optionElement);
    }

    radarStationsSelect.selectedIndex = 0;
}, true);

// Add event listener to 'enable radar' checkbox, to enable/disable radar selects.
document.getElementById('canw-radarEnable').addEventListener('click', function(aEvent) {
    var radarProvinces = document.getElementById('canw-radarProvinces');
    var radarStations = document.getElementById('canw-radarStations');
    radarProvinces.disabled = !radarProvinces.disabled;
    radarStations.disabled = !radarStations.disabled;
}, true);

// Add event listener to warnings checkbox, to enable/disable warning once checkbox.
document.getElementById('canw-warnings').addEventListener('click', function(aEvent) {
    document.getElementById('canw-warningsOnce').disabled =
            !document.getElementById('canw-warnings').checked;
    document.getElementById('canw-warningsOnce').checked = false;
}, true);

// Add event listener to color checkboxes, to enable/disable colorpickers.
document.getElementById('canw-normal').addEventListener('click', function(aEvent) {
    var normalChecked = document.getElementById('canw-normal').checked;
    var textColorNormalPicker = document.getElementById('canw-textColorNormal');
    var backgroundColorNormalPicker = document.getElementById('canw-backgroundColorNormal');

    if ( normalChecked ) {
        textColorNormalPicker.disabled = false;
        backgroundColorNormalPicker.disabled = false;
    }
    else {
        textColorNormalPicker.disabled = true;
        backgroundColorNormalPicker.disabled = true;
        textColorNormalPicker.value = '';
        backgroundColorNormalPicker.value = '';
        textColorNormalPicker.style.removeProperty('background-color');
        backgroundColorNormalPicker.style.removeProperty('background-color');
    }
}, true);

document.getElementById('canw-priorityLow').addEventListener('click', function(aEvent) {
    var priorityLowChecked = document.getElementById('canw-priorityLow').checked;
    var textColorLowPicker = document.getElementById('canw-textColorLow');
    var backgroundColorLowPicker = document.getElementById('canw-backgroundColorLow');

    if ( priorityLowChecked ) {
        textColorLowPicker.disabled = false;
        backgroundColorLowPicker.disabled = false;
    }
    else {
        textColorLowPicker.disabled = true;
        backgroundColorLowPicker.disabled = true;
        textColorLowPicker.value = '';
        backgroundColorLowPicker.value = '';
        textColorLowPicker.style.removeProperty('background-color');
        backgroundColorLowPicker.style.removeProperty('background-color');
    }
}, true);

document.getElementById('canw-priorityMedium').addEventListener('click', function(aEvent) {
    var priorityMediumChecked = document.getElementById('canw-priorityMedium').checked;
    var textColorMediumPicker = document.getElementById('canw-textColorMedium');
    var backgroundColorMediumPicker = document.getElementById('canw-backgroundColorMedium');

    if ( priorityMediumChecked ) {
        textColorMediumPicker.disabled = false;
        backgroundColorMediumPicker.disabled = false;
    }
    else {
        textColorMediumPicker.disabled = true;
        backgroundColorMediumPicker.disabled = true;
        textColorMediumPicker.value = '';
        backgroundColorMediumPicker.value = '';
        textColorMediumPicker.style.removeProperty('background-color');
        backgroundColorMediumPicker.style.removeProperty('background-color');
    }
}, true);

document.getElementById('canw-priorityHigh').addEventListener('click', function(aEvent) {
    var priorityHighChecked = document.getElementById('canw-priorityHigh').checked;
    var textColorHighPicker = document.getElementById('canw-textColorHigh');
    var backgroundColorHighPicker = document.getElementById('canw-backgroundColorHigh');

    if ( priorityHighChecked ) {
        textColorHighPicker.disabled = false;
        backgroundColorHighPicker.disabled = false;
    }
    else {
        textColorHighPicker.disabled = true;
        backgroundColorHighPicker.disabled = true;
        textColorHighPicker.value = '';
        backgroundColorHighPicker.value = '';
        textColorHighPicker.style.removeProperty('background-color');
        backgroundColorHighPicker.style.removeProperty('background-color');
    }
}, true);

document.getElementById('canw-priorityUrgent').addEventListener('click', function(aEvent) {
    var priorityUrgentChecked = document.getElementById('canw-priorityUrgent').checked;
    var textColorUrgentPicker = document.getElementById('canw-textColorUrgent');
    var backgroundColorUrgentPicker = document.getElementById('canw-backgroundColorUrgent');

    if ( priorityUrgentChecked ) {
        textColorUrgentPicker.disabled = false;
        backgroundColorUrgentPicker.disabled = false;
    }
    else {
        textColorUrgentPicker.disabled = true;
        backgroundColorUrgentPicker.disabled = true;
        textColorUrgentPicker.value = '';
        backgroundColorUrgentPicker.value = '';
        textColorUrgentPicker.style.removeProperty('background-color');
        backgroundColorUrgentPicker.style.removeProperty('background-color');
    }
}, true);

// Add event listener to the Rebuild Toolbar Display button.
document.getElementById('canw-buttonRebuildToolbar').addEventListener('click', function(aEvent) {
    self.port.emit('rebuild-click');
}, true);

// Add event listeners to our Ok and Cancel buttons.
document.getElementById('canw-buttonOk').addEventListener('click', function(aEvent) {
    // Validate and return options to add-on code.
    var minutes = document.getElementById('canw-minutes').value;

    if ( !isNaN(minutes) && minutes > 9 && minutes < 721 ) {
        // Location tab.
        var provincesSelect = document.getElementById('canw-provinces');
        var provinceIndex = provincesSelect.selectedIndex;
        var provinceCode = provincesSelect.value;

        var sitesSelect = document.getElementById('canw-sites');
        var siteIndex = sitesSelect.selectedIndex;
        var siteCode = sitesSelect.value;

        // Radar tab.
        var radarProvincesSelect = document.getElementById('canw-radarProvinces');
        var radarProvinceIndex = radarProvincesSelect.selectedIndex;

        var radarStationsSelect = document.getElementById('canw-radarStations');
        var radarStationIndex = radarStationsSelect.selectedIndex;
        var radarStation = radarStationsSelect.value.split('|');
        var radarStationName = radarStation[0];
        var radarStationCode = radarStation[1];
        
        var radarEnabled = document.getElementById('canw-radarEnable').checked;

        // Display tab.
        var showTemperature = document.getElementById('canw-temperature').checked;
        var showWind = document.getElementById('canw-wind').checked;
        var showWindChill = document.getElementById('canw-windChill').checked;
        var showHumidity = document.getElementById('canw-humidity').checked;
        var showHumidex = document.getElementById('canw-humidex').checked;
        var showCondition = document.getElementById('canw-condition').checked;
        var showConditionIcon = document.getElementById('canw-conditionIcon').checked;
        var toolbarDisplayEnabled = showTemperature || showWind || showWindChill ||
                                    showHumidex || showCondition;
        var conditionsPanelEnabled = document.getElementById('canw-showAllInPanel').checked;
        var warningPanelEnabled = document.getElementById('canw-warnings').checked;
        var showWarningOnlyOnce = document.getElementById('canw-warningsOnce').checked;
    
        var showToday = document.getElementById('canw-today').checked;
        var showTonight = document.getElementById('canw-tonight').checked;
        var showTodayPlus1 = document.getElementById('canw-todayplus1').checked;
        var showTodayPlus2 = document.getElementById('canw-todayplus2').checked;
        var showDayLabel = document.getElementById('canw-dayLabel').checked;
        var showForecastTemperature = document.getElementById('canw-forecastTemp').checked;
        var showPop = document.getElementById('canw-pop').checked;
        var showForecastIcon = document.getElementById('canw-forecastIcon').checked;
        
        var forecastInToolbarEnabled = showToday || showTonight ||
                                       showTodayPlus1 || showTodayPlus2;

        // Style tab.
        var bold = document.getElementById('canw-bold').checked;
        var italic = document.getElementById('canw-italic').checked;
        
        var fontsizeSelect = document.getElementById('canw-sizes');
        var fontsizeIndex = fontsizeSelect.selectedIndex;


        var textColorNormal = document.getElementById('canw-textColorNormal').value;
        var backgroundColorNormal = document.getElementById('canw-backgroundColorNormal').value;
        var textColorLow = document.getElementById('canw-textColorLow').value;
        var backgroundColorLow = document.getElementById('canw-backgroundColorLow').value;
        var textColorMedium = document.getElementById('canw-textColorMedium').value;
        var backgroundColorMedium = document.getElementById('canw-backgroundColorMedium').value;
        var textColorHigh = document.getElementById('canw-textColorHigh').value;
        var backgroundColorHigh = document.getElementById('canw-backgroundColorHigh').value;
        var textColorUrgent = document.getElementById('canw-textColorUrgent').value;
        var backgroundColorUrgent = document.getElementById('canw-backgroundColorUrgent').value;

        var toolbarColorEnabled = textColorNormal || backgroundColorNormal ||
                                  textColorLow || backgroundColorLow ||
                                  textColorMedium || backgroundColorMedium ||
                                  textColorHigh || backgroundColorHigh ||
                                  textColorUrgent || backgroundColorUrgent;

        // Other tab.
        var frequencyMilli = minutes * 60000;
        var language = ( document.getElementById('canw-english').checked ) ? 'e' : 'f';

        var options = {
            language: language,
            location: {
                provinceIndex: provinceIndex,
                provinceCode: provinceCode,
                siteIndex: siteIndex,
                siteCode: siteCode
            },
            frequencyMilli: frequencyMilli,
            toolbarDisplay: {
                showTemperature: showTemperature,
                showWind: showWind,
                showWindChill: showWindChill,
                showHumidity: showHumidity,
                showHumidex: showHumidex,
                showCondition: showCondition,
                showConditionIcon: showConditionIcon
            },
            forecastInToolbar: {
                showToday: showToday,
                showTonight: showTonight,
                showTodayPlus1: showTodayPlus1,
                showTodayPlus2: showTodayPlus2,
                showDayLabel: showDayLabel,
                showForecastTemperature: showForecastTemperature,
                showPop: showPop,
                showForecastIcon: showForecastIcon
            },
            toolbarStyle: {
                bold: bold,
                italic: italic,
                fontsizeIndex: fontsizeIndex,
                color: {
                    normal: [textColorNormal, backgroundColorNormal],
                    priorityLow: [textColorLow, backgroundColorLow],
                    priorityMedium: [textColorMedium, backgroundColorMedium],
                    priorityHigh: [textColorHigh, backgroundColorHigh],
                    priorityUrgent: [textColorUrgent, backgroundColorUrgent]
                }
            },
            radar: {
                provinceIndex: radarProvinceIndex,
                stationIndex: radarStationIndex,
                stationName: radarStationName,
                stationCode: radarStationCode
            },
            radarEnabled: radarEnabled,
            toolbarDisplayEnabled: toolbarDisplayEnabled,
            forecastInToolbarEnabled: forecastInToolbarEnabled,
            toolbarColorEnabled: toolbarColorEnabled,
            conditionsPanelEnabled: conditionsPanelEnabled,
            warningPanelEnabled: warningPanelEnabled,
            showWarningOnlyOnce: showWarningOnlyOnce
        };

        self.port.emit('ok-click', options);
    }
    else {
        self.port.emit('error',
            ( document.getElementById('canw-english').checked ) ?
             'Invalid minutes!' : 'Valeur non valide pour les minutes!');
    }

    aEvent.preventDefault();
}, true);

document.getElementById('canw-buttonCancel').addEventListener('click', function(aEvent) {
    self.port.emit('cancel-click');
    aEvent.preventDefault();
}, true);
